import { Injectable } from "@angular/core";

@Injectable()
export class transform {
    public statuss = [
        {
            value: 1001,
            label: '正常运行',
        },
        {
            value: 1002,
            label: '尚未安装',
        },
        {
            value: 1003,
            label: '已经停用',
        },
        {
            value: 4444,
            label: '正在报警',
        },
    ];

    types = [
        {
            value: 1,
            label: '机电井',
        },
        {
            value: 2,
            label: '管网井',
        },
    ];

    usages = [
        {
            value: 1,
            label: '工业用水',
        },
        {
            value: 2,
            label: '农业用水',
        },
        {
            value: 3,
            label: '生态用水',
        },
        {
            value: 4,
            label: '生活用水',
        },
    ];

    departments = [
        {
            label: '水利局',
            value: 1,
        },
    ];

    licenseStates = [
        {
            label: '可用',
            value: 1,
        },
        {
            label: '不可用',
            value: 2,
        },
    ];

    transObjValueToStr = (obj, num) => {
        const idx = obj.findIndex((item) => item.value === num);
        if (idx >= 0) {
            return obj[idx].label;
        }
        return '';
    };

    transWellUsageToStr = (num) => {
        return this.transObjValueToStr(this.usages, num);
    };

    transWellStatusToStr = (num) => {
        return this.transObjValueToStr(this.statuss, num);
    };

    transWellTypeToStr = (num) => {
        return this.transObjValueToStr(this.types, num);
    };

    transDepartmentsToStr = (num) => {
        return this.transObjValueToStr(this.departments, num);
    };
}
